import '@scss/header.scss';
import '@scss/addQue.scss';
import "@scss/motaikuang.scss";
import "bootstrap/dist/css/bootstrap.css"
import "bootstrap/dist/js/bootstrap.js"
import http from "../utils/request.js";
import {renderName} from "./render.js";

(async function () {
    renderName();
    let { getAllKnow } = await http({ url: "/api/addQue/getAllKnow", type: "get" });
    let content = getAllKnow.map(item => {
        return `<option value=${item._id}>${item.KnowledgePoint}</option>`
    })

    $("#knowType").html(content);

})();


$("body").on("click", "#addTi",async function () {
    let question = $("#question").val();
    let analysis = $("#analysis").val();
    let answer = [$("#chooseA").val(), $("#chooseB").val(), $("#chooseC").val(), $("#chooseD").val()];
    let KnowledgePointId = $("#knowType").val();
    let RightKey = $("#correct").val();
    let score = parseInt($("#score").val());

    let { code} = await http({ url: "/api/addQue/addQuestions", type: "post",data:{question,analysis,answer:JSON.stringify(answer),KnowledgePointId,RightKey,score} });
    if(code){
        alert("添加成功")
    }
})